//
//  LzwUserSettingVC.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/13.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwUserSettingVC.h"
#import "LzwbaseTableView.h"
#import "LzwBaseImageView.h"
#import "UMSocial.h"
#import "LzwMyUserProblemVc.h"
#import "LzwUserMyCollectVc.h"


@interface LzwUserSettingVC ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) LzwbaseTableView *mySetTableView;

@end

@implementation LzwUserSettingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"我的设置";
    
    UIImage *image = [UIImage imageNamed:@"return.png"];
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(LeftButtonAction:)];
    
    self.mySetTableView = [[LzwbaseTableView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    [self.view addSubview:self.mySetTableView];
    
    self.mySetTableView.delegate = self;
    self.mySetTableView.dataSource = self;
    
    [self.mySetTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row == 0) {
        UIImage *icon = [UIImage imageNamed:@"55.png"];
        LzwBaseImageView *myimage = [[LzwBaseImageView alloc]initWithImage:icon];
        myimage.frame = CGRectMake(18 * WIDTH, 18 * WIDTH, 18 * WIDTH, 18 * WIDTH);
        [cell addSubview:myimage];
        
        cell.detailTextLabel.text = @">";
        
        cell.indentationWidth = 20.0f * WIDTH;
        cell.indentationLevel = 2 * WIDTH;
        cell.textLabel.text = @"我的收藏";
        cell.textLabel.textColor = [UIColor orangeColor];
    }
        
    else if (indexPath.row == 1){
        UIImage *icon = [UIImage imageNamed:@"share1.png"];
        LzwBaseImageView *myimage = [[LzwBaseImageView alloc]initWithImage:icon];
        myimage.frame = CGRectMake(15 * WIDTH, 15 * WIDTH, 20 * WIDTH, 20 * WIDTH);
        [cell addSubview:myimage];
        cell.detailTextLabel.text = @">";
        
        cell.indentationWidth = 20.0f * WIDTH;
        cell.indentationLevel = 2 * WIDTH;
        cell.textLabel.text = @"分享应用";
        cell.textLabel.textColor = [UIColor orangeColor];
        
    }else{
        UIImage *icon = [UIImage imageNamed:@"wenti.png"];
        LzwBaseImageView *myimage = [[LzwBaseImageView alloc]initWithImage:icon];
        myimage.frame = CGRectMake(15 * WIDTH, 15 * WIDTH, 23 * WIDTH, 23 * WIDTH);
        [cell.contentView addSubview:myimage];
        
        cell.detailTextLabel.text = @">";
        
        cell.indentationWidth = 20.0f * WIDTH;
        cell.indentationLevel = 2 * WIDTH;
        cell.textLabel.text = @"常见问题";
        cell.textLabel.textColor = [UIColor orangeColor];
        
        
    }
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}

//点击cell触发方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        
        LzwUserMyCollectVc *collectV = [[LzwUserMyCollectVc alloc]init];
        
        [self.navigationController pushViewController:collectV animated:YES];
        
        
    }else if (indexPath.row == 1){
        
        //注意：分享到微信好友、微信朋友圈、微信收藏、QQ空间、QQ好友、来往好友、来往朋友圈、易信好友、易信朋友圈、Facebook、Twitter、Instagram等平台需要参考各自的集成方法
        [UMSocialSnsService presentSnsIconSheetView:self
        appKey:@"56911ce367e58e117a002ed8"
        shareText:@"http://www.ibantang.com"
        shareImage:[UIImage imageNamed:@"icon.png"]
        shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina, UMShareToRenren, UMShareToTencent,  nil]
                                           delegate:nil];
        
        
        
        
        
        
    }else{
        
        LzwMyUserProblemVc *problem = [[LzwMyUserProblemVc alloc]init];
        
        [self.navigationController pushViewController:problem animated:YES];
    }
    
    
}





//返回按钮
- (void)LeftButtonAction:(UIBarButtonItem *)bar{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
